#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int Ackmann(int n, int m)
{
	if (m == 0)
		return n + 1;
	if (m > 0 && n == 0)
		return Ackmann(m, 1);
	if (m > 0 && n > 0)
		return Ackmann(m - 1, Ackmann(m, n - 1));
	return 0;
}

int main() {
	int m = 0, n = 0;
	scanf("%d %d", &n, &m);
	printf("%d", Ackmann(n,m));
	return 0;
}